var mysql = require('mysql');
var connection = mysql.createConnection({
    host:'localhost',
    user:'root',
    password:'qq11yahoo',
    database:'hash',
    port:'3306'
});

function connectDB() {
    connection.connect();
}

function addInfoHash(hash){
    var  addSql = 'INSERT INTO info(infoHash) VALUES(?)';
    var  addSqlParams = [hash];
    connection.query(addSql,addSqlParams,function (err,result) {
        if (err){
            console.log('[INSERT ERROR] - ', err.message);
            return
        }
        console.log('--------------------------INSERT----------------------------');
    });
}


module.exports = {
    connectDB,
    addInfoHash
};
